const { exec, escape } = require("../db/mysql");
const getCookieExpires = () => {
  const date = new Date();
  return date.now().getTime() + 30 * 1000 * 60;
};
const login = (username, password) => {
  username = escape(username);
  password = escape(password);
  const sql = `
  select username,realname from users where username=${username} and password = ${password}
  `;
  console.log(sql, "loginsql");
  return exec(sql).then((rows) => {
    // req.setHead("SET-COOKIE", "");
    console.error(rows[0], "in login sql");
    return rows[0] || {};
  });
};
module.exports = {
  login,
};
